﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using WordService.Data.IDAL;
using System.Reflection;

namespace WordService.Data
{
    /// <summary>
    /// 数据层Manager，管理数据库连接
    /// </summary>
    public sealed class DALManager
    {
        private static readonly String DataPath = ConfigurationManager.AppSettings["DLLPath"];

        private DALManager() { }

        public static IArticleDAL CreateArticleDAL()
        {
            String className = DataPath + ".Data.DAL.ArticleDAL";
            return (IArticleDAL)Assembly.Load(DataPath).CreateInstance(className);
        }

        public static IInstitutionDAL CreateInstitutionDAL()
        {
            String className = DataPath + ".Data.DAL.InstitutionDAL";
            return (IInstitutionDAL)Assembly.Load(DataPath).CreateInstance(className);
        }

        public static IAuthorDAL CreateAuthorDAL()
        {
            String className = DataPath + ".Data.DAL.AuthorDAL";
            return (IAuthorDAL)Assembly.Load(DataPath).CreateInstance(className);
        }

        public static IKeywordDAL CreateKeywordDAL()
        {
            String className = DataPath + ".Data.DAL.KeywordDAL";
            return (IKeywordDAL)Assembly.Load(DataPath).CreateInstance(className);
        }
    }
}
